<template>

    <h2>修改会员</h2>
    
    
    <table class="table table-border">
    <thead>
    
    
        <tr>
            <th>
                会员名称
            </th>
    
            <th>
                <input type="text" v-model="nn.mname">
            </th>
        </tr>
    
        <tr>
            <th>
                会员手机号
            </th>
    
            <th>
                <input type="text"  v-model="nn.phone">
            </th>
        </tr>
    
        <tr>
            <th>
                会员密码
            </th>
    
            <th>
                <input type="password"  v-model="nn.mpwd">
            </th>
        </tr>
    
    
        <tr>
            <th>
                会员生日
            </th>
    
            <th>
                <input type="date"  v-model="nn.shengRi">
            </th>
        </tr>
    
    
        <tr>
            <th>
                会员身份证
            </th>
    
            <th>
                <input type="text"  v-model="nn.shenFenZheng">
            </th>
        </tr>
    
    
        <tr>
            <th>
                会员会员卡号
            </th>
    
            <th>
                <input type="text"  v-model="nn.huiYuanKa">
            </th>
        </tr>
    
    
        <tr>
            <th>
                等级
            </th>
    
            <th>
               <select  v-model="nn.did" >
                    <option :value="-1">--请选择---</option>
                    <option  v-for="item in ab" :value="item.dId" >{{ item.dName }}</option>
               </select>
            </th>
        </tr>
    
    
    
        <tr>
            <th>
               
            </th>
    
            <th>
          
                <button @click="upMe" value="修改">修改</button>
              
            </th>
        </tr>
    
    </thead>
        
    </table>
    
    
    
    
    <tbody>
    
      
    </tbody>
    
    
    </template>
    
    
    <script setup lang="ts">
    
    const ab= ref([{
    
    
        dId: -1,
        dName: "--请选择---"
    
    
    }])
    
    import axios from 'axios';
    import {onMounted, ref}  from'vue';
    import{useRouter,useRoute,createRouter} from 'vue-router'
    
        onMounted(()=>{
    
            
            XiaLa()
    
    
        })
    
    const route=useRoute();
        const router = useRouter();
        const XiaLa=()=>{
                axios.get('https://localhost:7010/api/DengJI/ShowDj').then(res=>{
    
                        
                    ab.value=res.data;
                })
                .catch(error=>{
                       
                    console.log(error);
                })
    
        }
    
    const ccc=route.params.M1id;
    const nn =ref({
    
        mId: ccc,
      mname: "",
      phone: "",
      mpwd: "",
      shengRi: "",
      shenFenZheng: "",
      huiYuanKa: "",
      did: -1
    
    })
    
    
    
    console.log(nn.value)
    
      
    const upMe =()=>{
     
        
    
    
        axios.put('https://localhost:7010/api/Member/UpMe',nn.value).then(res=>{
    
            if(res.data>0)
        {
          
            alert('修改成功')
            router.push('/ShowMember')
    
        
        }
        else if(res.data==-1)
        {
            alert('身份证号重复')
        }
        else
        {
            alert('添加失败')
        }
        
            
    
    
        }).catch(x=>{
    
            console.log(x.data);
            })
    
    
    }
    
    
    
    
    
    </script>